package com.skhu.as.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.skhu.as.domain.FaultHandling;
import com.skhu.as.service.FaultHandlingS;

public class FaultHandlingDelC extends AbstractController {
	
	private FaultHandlingS faultHandlingS;
	private String successView;
	
	public void setFaultHandlingS(FaultHandlingS faultHandlingS) {
		this.faultHandlingS = faultHandlingS;
	}
	public void setSuccessView(String successView) {
		this.successView = successView;
	}

	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		ModelAndView mav = new ModelAndView(successView);
		
		int faultHandlingNo = ServletRequestUtils.getIntParameter(request, "faultHandlingNo");
		
		FaultHandling faultHandling = faultHandlingS.getFaultHandlingByNo(faultHandlingNo);
		faultHandlingS.deleteRequester(faultHandling.getRequesterNo());
		faultHandlingS.deleteFaultHandling(faultHandling.getFaultHandlingNo());
		
		return mav;
	}
	
}
